<?php
header("Content-type:text/html; charset=utf-8");
include ("../conn.php");
include ("../include/function.php");
$parentid = $_GET['parentid'];
$parentname = $_GET['parentname'];

$id = "";
if(isset($_GET['id'])){
	$id = $_GET['id'];
}
$act = "";
if(isset($_GET['act'])){
	$act =$_GET['act'];
}

//删除操作
if(isset($_GET['id'])&&$_GET['act']=="del")
{
	$selectSQL = "select FORIGINALFILE from ".$databasepre."file where PARENTID=".$id;
	//echo $selectSQL;
	$query = mysql_query($selectSQL);
	while($row=mysql_fetch_array($query))
	{
		@unlink("..".DIRECTORY_SEPARATOR."upload".DIRECTORY_SEPARATOR."original".DIRECTORY_SEPARATOR.$row['FORIGINALFILE']);
		@unlink("..".DIRECTORY_SEPARATOR."upload".DIRECTORY_SEPARATOR."big".DIRECTORY_SEPARATOR.$row['FORIGINALFILE']);
		@unlink("..".DIRECTORY_SEPARATOR."upload".DIRECTORY_SEPARATOR."small".DIRECTORY_SEPARATOR.$row['FORIGINALFILE']);
	}
	$deleteSQL="delete from ".$databasepre."file where PARENTID=".$id;
	mysql_query($deleteSQL);

	$deleteSQL="delete from ".$databasepre."product where ID=".$id;
	mysql_query($deleteSQL);
	//echo "删除成功!<a href=admin_product_list.php?pagesize=1&currentpage=2>返回</a>";exit;
	//echo "<script>window.location.href='admin_product_list.php?pagesize=1&currentpage=2&parentid=".$parentid."&parentname=".$parentname."'</script>";
}
?>
<html><head>
<meta http-equiv=Content-Type content=text/html;charset=utf-8>
<link href="images/skin.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #EEF2FB;
}
-->
</style>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
    <td valign="top" background="images/content-bg.gif">
		<table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
		  <tr><td height="31"><div class="titlebt">产品管理</div></td></tr>
		</table>
	</td>
    <td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9">
	<!-- 网页内容部分开始 -->


	<table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr><td height="13" valign="top">&nbsp;</td></tr>
	  <tr><td class="left_txt">当前位置：产品分类管理 - > <?php echo $_GET['parentname']?></td></tr>
	  <!-- 一根线 -->
	  <tr><td><table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC"><tr><td></td></tr></table></td></tr>
	  <!-- 说明信息 -->

	  <tr><td><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
				  <tr><td class="left_bt2">&nbsp;&nbsp;&nbsp;&nbsp;产品管理【<a href="admin_product_add.php?act=create&parentid=<?php echo $parentid ?>&parentname=<?php echo urlencode($parentname) ?>"> 新 增 </a>】</td></tr>
				</table>
		</td>
      </tr>
	  <tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0" align=left>
				<form method=POST action="">

					<tr bgcolor="#f2f2f2">
						<th width="1%" class="left_txt" align=left></th>
						<th width="35%" height="30" class="left_txt2" align=left>产品名称</th>
						<th width="30%" height="30" class="left_txt2" align=left>产品名称[中文]</th>
						<th width="4%" height="30" class="left_txt2" align=left>图片</th>
						<th width="10%" class="left_txt2" align=left>排序[升序]</th>
						<th width="10%" class="left_txt2" align=left>发布时间</th>
						<th width="10%" class="left_txt2" align=left>操作</th>
					</tr>
					<?php
					$tdstyle="";
					$tdi = 0;
					$selectSQL="select * from ".$databasepre."product where PARENTID=".$parentid." order by SEQ asc,ID DESC";
					$query=mysql_query($selectSQL);

					while($row=mysql_fetch_array($query))
					{
						$tdi = $tdi + 1;
						if($tdi%2 == 1) { $tdstyle = "f2f2f2"; }else{ $tdstyle = ""; }
						$picnum = getOneFiledbySQL("select count(*) AS FILEDNAME from ".$databasepre."file where PARENTID=".$row['ID']);
						$piccolor = $picnum==0?"style='color:red'":$picnum;
						echo '<tr bgcolor='.$tdstyle.'>';
						echo '<td height="30"></td>';
						echo '<td align=left>'.$row['PNAME'].'</td>';
						echo '<td align=left>'.$row['PNAME2'].'</td>';
						echo '<td align=left '.$piccolor.'>'.$picnum.'张</td>';//
						echo '<td align=left >'.$row['SEQ'].'</td>';
						echo '<td align=left>'.$row['CREATEDATE'].'</td>';
						echo '<td align=left><a href="admin_product_add.php?act=update&parentid='.$parentid.'&parentname='.urlencode($parentname).'&id='.$row['ID'].'">修改</a> -- ' .
								'<a href=?act=del&parentid='.$parentid.'&parentname='.urlencode($parentname).'&id='.$row['ID'].'>删除</a></td>';
						echo '</tr>';
					}
					if($tdi == 0) {echo "<tr><td colspan=5 align=center>暂无产品信息！</td></tr>";}
					?>



				</form>
			  </table>
			</td>
		</tr>



	 </table>






	<!-- 网页内容部分结束 -->
	</td>
    <td background="images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="bottom" background="images/mail_leftbg.gif"><img src="images/buttom_left2.gif" width="17" height="17" /></td>
    <td background="images/buttom_bgs.gif"><img src="images/buttom_bgs.gif" width="17" height="17"></td>
    <td valign="bottom" background="images/mail_rightbg.gif"><img src="images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>
</body>
</html>
